#列表的CRUD
list1 = ['a', 1, 2.1]
list2 = ['ba']

#Create
list1.append('b')
print(list1+list1)
list1 += list2
print(list1)
list3 = list1*4
print(list3)
list3 *=1
print(list3)
list2.insert(0, "ashg")
print(list2)
#Retrieve
print(list1[2])
print(list1[0:3])
print(list1[:2])
print(list1[3:])
print(list1.index(1))
#Update
list2[0:2] = 'bbc', 'ccs', 'ccs'
print(list2)
#Delete
list1.pop(1)
print(list1)
print(list1.remove('a'))
del list1[2]
print(list1)
#统计
list1.count('1')
#排序
#从小到大
list4 = [1, 2, 8, 5, 74, 5, 344, 67]
print(list4.sort())
print(sorted(list2))
#从大到小
print(list4.sort(reverse=True))
#倒序
print(list1.reverse())
print(reversed(list2))

#元组
da = (23, 423, 2, 432, 7)
#Create
#Retrieve
print(da[2])
print(da[1:3])
print(da[:2])
print(da[3:])
print(da.index(7))
#Update
#Delete

#字典
dict1 = {'a': 2, 1: 'd', 1.2: 'mn'}
#Create
dict1[0] = '大'
print(dict1)
print(dict1.setdefault('b', 100))
print(dict1)
dict1.update({'再bb': '打死你', '老师又': '夸我'})
print(dict1)
#Retrieve
print(dict1['老师又'])
print(dict1.get('b', 20))
print(dict1.keys())
print(dict1.values())
print(dict1.items())
#Update
dict1['b'] = '火大'
dict1.update({'sjd': '杰伦', 'excuse': 'me'})
#Delete
dict1.pop('b')

#集合
nice = set()
#Create
nice.add('b')
#Retrieve
print('b' in nice)
#Update
print(nice.update({1, 2, 5}))
print(nice)
nice1 = {998, 12, 23, 22}
print(nice.union(nice1))
#Delete
print(nice.pop())
print(nice)
print(nice.remove(2))
print(nice)
